<template>
  <div id="login-div">
    <div id="login-herder">标识节点上传3</div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="用户名">
        <el-input v-model="form.username"></el-input>
      </el-form-item>


      <el-form-item label="密码">
        <el-input v-model="form.password" show-password></el-input>
      </el-form-item>


      <el-form-item>
        <el-button type="primary" @click="onSubmit">登录</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>


  </div>
</template>

<script>


export default {


  name: "Login",
  data() {
    return {

      form: {
        username: '',
        password: '',
        token: '',
      },
      wx: {
        "id": 1,
        "prefix": "88.175.985",
        "handle": "88.175.985/YAV716AD000381030810966502",
        "templateVersion": "yav产品",
        "value": [
          {
            "data": {
              "format": "string",
              "value": "88.175.985/YAV716AD000381030810966502"
            },
            "index": 2000,
            "type": "ip"
          },
          {
            "data": {
              "format": "string",
              "value": "16AD智能多功能信号采集卡"
            },
            "index": 2001,
            "type": "category"
          },
          {
            "data": {
              "format": "string",
              "value": "十六路AI"
            },
            "index": 2002,
            "type": "purpose"
          },
          {
            "data": {
              "format": "string",
              "value": "符合EC60068国际标准，符合中国GB2423《电工电子产品环境试验方法》国家标准"
            },
            "index": 2003,
            "type": "innovate"
          },
          {
            "data": {
              "format": "string",
              "value": "https://space.bilibili.com/508092984?spm_id_from=333.788.b_765f7570696e666f.2"
            },
            "index": 2004,
            "type": "videopath"
          },
          {
            "data": {
              "format": "string",
              "value": "http://www.yav123.com/Ziyuan_Show.aspx?channel_id=24&category_id=101&id=506"
            },
            "index": 2005,
            "type": "downloadpath"
          }
        ]
      },
      signdata: {},
      id: "",
      zn: {
        "handle": "88.175.985/YAV716AD000071070B25000018"
      }

    }
  },

  methods: {


    onSubmit: function () {

      /*   this.$router.push("/main")*/


      /*

            this.$axios.post("/api/identity/token", {
              "username":"wangyaoqin",
              "password":"Wangyaoqin@yawei"
            },{
              emulateJSON: true
            }).then(
                res => {
                  if (res.data.status == 1) {

                    this.token=res.data.data.token,
                        alert(this.token);


                    this.$axios.post('/api/identityv2/data',this.wx,
                        {
                          headers:{
                            'Authorization':this.token
                          }
                        })
                        .then( res=> {
                          if(res.data.msg == 'success'){

                            console.log(res);

                          }else{

                            this.warning(res.data.msg)
                          }
                        }).catch( req=> {
                      console.log(req)
                    })

                  } else {
                    this.$message({
                      message: res.data.msg,
                      type: 'warning'
                    });

                  }


                }
            )
      */

      /*

            this.$axios.post("/yav/getregisterdata", {
              emulateJSON: true
            }).then(
                res => {
                  if (res.handle == null) {
                    this.signdata = res.data


                    this.$axios.post("/api/identity/token", {
                      "username": "wangyaoqin",
                      "password": "Wangyaoqin@yawei"
                    }, {
                      emulateJSON: true
                    }).then(
                        res => {
                          if (res.data.status == 1) {

                            this.token = res.data.data.token,



                            this.$axios.post('/api/identityv2/data', this.signdata,
                                {
                                  headers: {
                                    'Authorization': this.token
                                  }
                                })
                                .then(res => {
                                  if (res.data.msg == 'success') {

                                    console.log(res);

                                  } else {

                                    this.warning(res.data.msg)
                                  }
                                }).catch(req => {
                              console.log(req)
                            })

                          } else {
                            this.$message({
                              message: res.data.msg,
                              type: 'warning'
                            });

                          }


                        }
                    )


                  } else {
                    this.$message({
                      message: res.data.msg,
                      type: 'warning'
                    });

                  }


                }
            )
      */





      /*
        //标识增加



      */


      /*标识修改

                    this.$axios.put('/api/identityv2/data',this.wx,
                        {
                          headers:{
                            'Authorization':this.token
                          }
                        })
                        .then( res=> {
                          if(res.data.msg == 'success'){

                            console.log(res);

                          }else{

                            this.warning(res.data.msg)
                          }
                        }).catch( req=> {
                      console.log(req)
                    })   */


      /*标识删除

                    this.$axios({
                          method:'delete',
                          url:`/api/identityv2/data`,
                          headers:{
                            'Authorization':this.token
                          },
                          data: { "handle": "88.175.985/YAV716AD000071070B25000018",}
                        },
                    ).then(res=>{
                      console.log(res)
                    }).catch(req=>{
                      console.log(req)
                    })
      */


    },
    get()
    {
      this.$axios.get('/api/Test1.action/searchData').then((r)=>{
        console.log(r)
      })
    }
/*    get1() {
      this.$axios.post("/yav/getregisterdata", {
        emulateJSON: true
      }).then(
          res => {
            if (res.data.id!=0) {

              this.signdata = res.data,
                  this.id = res.data.id,


                  this.$axios.post("/yav/updatabyid", this.$qstring.stringify({id: this.id})).then(

                  )

              this.signdata = res.data


              this.$axios.post("/api/identity/token", {
                "username": "wangyaoqin",
                "password": "Wangyaoqin@yawei"
              }, {
                emulateJSON: true
              }).then(
                  res => {
                    if (res.data.status == 1) {
                      this.token = res.data.data.token,
                          this.$axios.post('/api/identityv2/data', this.signdata,
                              {
                                headers: {
                                  'Authorization': this.token
                                }
                              })
                              .then(res => {
                                if (res.data.message == 'success') {

                                  console.log(res);

                                }  else if (res.data.message == '标识已存在') {

                                  this.$axios.put('/api/identityv2/data',this.signdata,
                                      {
                                        headers:{
                                          'Authorization':this.token
                                        }
                                      })
                                      .then( res=> {
                                        if(res.data.msg == 'success'){

                                          console.log(res);

                                        }else{

                                          this.warning(res.data.msg)
                                        }
                                      }).catch( req=> {
                                    console.log(req)
                                  })

                                }
                              })

                    } else {
                      this.$message({
                        message: res.data.msg,
                        type: 'warning'
                      });

                    }


                  }
              )


            }


          }
      )
    }*/

  },


  mounted() {
    this.timer = setInterval(this.get, 5000);
  },
  beforeDestroy() {
    clearInterval(this.timer);
  }

}
</script>

<style scoped>
#login-div {
  width: 500px;
  margin: 0px auto;

}

#login-herder {
  text-align: center;
  font-size: 25px;
  font-family: sans-serif;
  padding: 15px;
  color: darkkhaki;
}
</style>